<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏商家合作平台</title>
    <script src="__JS__/jquery.js"></script>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <link rel="stylesheet" href="__STATIC__/boot/css/fileinput.css">
    <link rel="stylesheet" href="__STATIC__/css/boot.css">
    <script src="__STATIC__/boot/js/fileinput.js"></script>
    <script src="__STATIC__/boot/js/locales/zh.js"></script>
</head>
<body>
{include file="base/header" /}
<div style="height: 20px"></div>
<div style="width: 900px;margin: 0 auto">
    <form class="layui-form" action="{:url('business/goods/uploads')}" id="myform" name="myform" method="post" enctype="multipart/form-data">
        <input type="hidden" name="productid" />
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">商品名称</label>
            <div class="layui-input-block">
                <input type="text" name="pname" required  lay-verify="required" placeholder="产品名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">单价(单价)</label>
            <div class="layui-input-block">
                <input type="text" name="purchaseprice" required  lay-verify="required" placeholder="进价(元)" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">商品类型</label>
            <div class="layui-input-block">
                <select name="category" lay-verify="required">
                    {foreach $category as $val}
                        <option value="{$val.title}">{$val.title}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width: 100px">商品图片</label>
            <div class="layui-input-block">
                <div class="form-group">
                    <input type="file" class="file" id="img_url1" name="image_data[]" accept="image/*" multiple>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width: 100px">商品介绍</label>
            <div class="layui-input-block">
                <textarea name="introduce" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="width: 200px;margin: 0 auto;">
                <button type="button" onclick="insert()" class="btn btn-primary">添加</button>
            </div>
        </div>
    </form>
</div>

<script>
    id = '';
    //初始化表单
    layui.use('form', function(){

    });
    //多图上传
    $("#img_url1").fileinput({
        language: 'zh',
        browselable:'请选择图片',
        showCancel:false,//是否显示取消按钮
        uploadUrl: "{:url('business/goods/goodsuploadimage')}?id="+id, //上传后台操作的方法
        uploadAsync: false, //设置上传同步异步 此为同步
        async:false,
        maxFileSize: 200,
        showUpload: false, //是否显示上传按钮,跟随文本框的那个
        showRemove : true, //显示移除按钮,跟随文本框的那个
        allowedFileExtensions: ['jpg','png','gif','jpeg'], //限制上传文件后缀
        showCaption: false,//是否显示标题
        maxFileCount:9
    });
    //添加
    function insert() {
        window.myform.submit();
    }
</script>
</body>
</html>